package b1.project.common.base;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.dromara.autotable.annotation.ColumnComment;
import org.dromara.autotable.annotation.ColumnType;
import org.dromara.autotable.annotation.PrimaryKey;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author sun
 * @date 2024/9/27 15:11
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BaseEntity implements Serializable {
    @PrimaryKey(autoIncrement = false)//声明该列为主键 非自增
    @ColumnType(value = "varchar", length = 32)
    //@Id(keyType = KeyType.Generator, value = "myUUID")
    @Id(keyType = KeyType.Auto)
    private String id;

    @ColumnComment(value = "创建人id")
    @ColumnType(value = "varchar", length = 32)
    private String createById;

    @ColumnComment(value = "创建人")
    @ColumnType(value = "varchar", length = 32)
    private String createByName;

    @Column(onInsertValue = "now()")
    @ColumnComment(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @ColumnComment(value = "更新用户id")
    @ColumnType(value = "varchar", length = 32)
    private String updateById;

    @ColumnComment(value = "更新用户")
    @ColumnType(value = "varchar", length = 32)
    private String updateByName;

    @Column(onUpdateValue = "now()")
    @ColumnComment(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    //@Column(isLogicDelete = true)
    @ColumnComment(value = "逻辑删除 0否1是")
    private Boolean isDelete;

    @ColumnComment(value = "版本号")
    //@Column(version = true)
    private Long version;
}
